/* 枚举 */
/* // 初始值默认为 0
enum JiShiEnum {
    REDJ,
    BLUEJ,
    GREENJ,
}

// 设置初始值
enum JiShiEnum2 {
    REDJ = 8,
    BLUEJ,
    GREENJ,
}
const jishi: JiShiEnum2 = JiShiEnum2.BLUEJ;
console.log(jishi); // 9

// 字符串枚举，每个都需要声明
enum JiShiEnum3 {
    REDJ = "8号",
    BLUEJ = "9号",
    GREENJ = "10号",
} */


/* 泛型 */
/* // T 自定义名称
function myFun<T>(params: T[]) {
    return params;
}
console.log(myFun<string>(["123", "456"]));

// 定义多个泛型
function join<T, P>(first: T, second: P) {
    return `${first}${second}`;
}
console.log(join<number, string>(1, "2")); */

interface Waiter {
    anjiao: boolean;
    say: () => {};
}

interface Teacher {
    anjiao: boolean;
    skill: () => {};
}



/* 断言 */
/* 
function judgeWho(animal: Waiter | Teacher) {
    if (animal.anjiao) {
        (animal as Teacher).skill();
    } else {
        (animal as Waiter).say();
    }
}

judgeWho({
    anjiao: true,
    skill: () => {
        console.log("skill called");
        return {
            msg:"JS is good"
        }
    }
}) 
*/

/* in */
/* function judgeWho(animal: Waiter | Teacher) {
    if ("skill" in animal) {
        animal.skill();
    } else {
        animal.say();
    }
}

judgeWho({
    anjiao: true,
    skill: () => {
        console.log("skill called again");
        return {
            msg: "JS is good",
        };
    },
}); */

/* 类型注解 */
/* let count: number; // 类型注解
count = 123; */
